/*
 * User.java
 *
 * Created on 2007年3月31日, 上午2:01
 *
 * 用户信息域
 * 
 */

package cn.geckos.forum.domainobject;

import java.util.Date;


/**
 *
 *  User have all the properties that a real user have
 *
 * @author jeff
 */
public class User{
    
    public static final int ENABLED=0;
    public static final int DISABLED=1;
    
    private long id;
    private String name;
    private String nickname;
    private String password;
    private String email;
    private int gender;
    private int profession;
    private String icon;
    private int power;
    private Date registerDate;
    private Date logoutDate;
    private int enabled;
   
    public User() {
    }
    
    private void setId(long id)
    {
        this.id = id;
    }
    public long getId()
    {
        return this.id;
    }
     /**
     *  set name of the person
     *@param java.lang.String
     */
    public void setName(String name)
    {
        this.name = name;
    }
    /**
     *  get name of the person
     *@param java.lang.String
     */
    public String getName()
    {
        return this.name;
    }
    
    /**
     *  set gender of the person
     *@param java.lang.String
     */
    public void setGender(int gender)
    {
        this.gender = gender;
    }
    /**
     *  get gender of the person
     *@param java.lang.String
     */
    public int getGender()
    {
        return this.gender;
    }
    
    public void setEmail(String email)
    {
        this.email = email;
    }
    public String getEmail()
    {
        return this.email;
    }
    
    public void setProfession(int selectNo)
    {
        this.profession = selectNo;
    }
    public int getProfession()
    {
        return this.profession;
    }
    
    public void setPassword(String password)
    {
        this.password = password;
    }
    public String getPassword()
    {
        return this.password;
    }
    
    public void setNickname(String nickname)
    {
        this.nickname = nickname;
    }
    public String getNickname()
    {
        return this.nickname;
    }
    
    public void setIcon(String path)
    {
        this.icon = path;
    }
    public String getIcon()
    {
        return this.icon;
    }
    
    public void setPower(int power)
    {
        this.power = power;
    }
    public int getPower()
    {
        return this.power;
    }
    
    public void setRegisterDate(Date rd)
    {
        this.registerDate = rd;
    }
    public Date getRegisterDate()
    {
        return this.registerDate;
    }
    
    public void setLogoutDate(Date ld)
    {
        this.logoutDate = ld;
    }
    public Date getLogoutDate()
    {
        return this.logoutDate;
    }
    public int getEnabled() {
        return enabled;
    }

    public void setEnabled(int enabled) {
        this.enabled = enabled;
    }
    
    public String toString()
    {
        StringBuffer sb = new StringBuffer();
        sb.append("User Object: ");
        sb.append(this.getId());
        sb.append(this.getName());
        sb.append(this.getNickname());
        sb.append(this.getGender());
        sb.append(this.getEmail());
        sb.append(this.getPassword());
        sb.append(this.getIcon());
        sb.append(this.getRegisterDate());
        sb.append(this.getPower());
        sb.append(this.getProfession());
        sb.append(this.getLogoutDate());
        return sb.toString();
    }
    
    public boolean equals(Object o)
    {
        if(o != this)
        {
            if(o instanceof User)
            {
                User u = (User)o;
                if(this.getName().equals(u.getName()) &&
                    this.getNickname().equals(u.getNickname()) &&
                    this.getEmail().equals(u.getEmail()) &&
                    this.getGender() == u.getGender() &&
                    this.getPassword().equals(u.getPassword()) &&
                    this.getPower() == u.getPower() &&
                    this.getRegisterDate().equals(u.getRegisterDate()) &&
                    this.getProfession()==u.getProfession() &&
                    this.getIcon().equals(u.getIcon()) &&
                    this.getLogoutDate().equals(u.getLogoutDate()))
                {
                    return true;
                }
            }else return false;
        }
        return true;
    }
}
